package com.jiuwu.spring.eshop.respository;

import com.jiuwu.spring.eshop.db.entity.Comment;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
public interface CommentRepository extends JpaRepository<Comment,Integer> {

    @Modifying
    @Query(value = "update Comment set commentReply = ?2 where orderId = ?1")
    void updateMemberInfo(Integer id,String commentReply);


    @Query(value = "select c from Comment c where c.orderId = ?1")
    List<Comment> findOrder(Integer orderId);

    @Modifying
    @Query(value = "delete from Comment where orderId = ?1")
    void delOrder(Integer orderId);


    List<Comment> findAllByGoodsNameLike(String goodsName);

    Page<Comment> findAll(Pageable pageable);

}
